int piece_square_values[BK+1][0x80] = {
    {}, {}, {}, {}, {}, {}, {}, {}, {}, // empties to get indexing right
{ // pawn
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,
-10,  2,  8, 15, 15,  8,  2,-10, 0, 0, 0, 0, 0, 0, 0, 0,
-11,  1,  7, 13, 13,  7,  1,-11, 0, 0, 0, 0, 0, 0, 0, 0,
-12,  0,  5, 12, 12,  5,  0,-12, 0, 0, 0, 0, 0, 0, 0, 0,
-14, -2,  3, 10, 10,  3, -2,-14, 0, 0, 0, 0, 0, 0, 0, 0,
-15, -4,  2,  9,  9,  2, -4,-15, 0, 0, 0, 0, 0, 0, 0, 0,
-16, -5,  1,  8,  8,  1, -5,-16, 0, 0, 0, 0, 0, 0, 0, 0,
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // knight
 -82, -16,  -5,   0,   0,  -5, -16, -82, 0, 0, 0, 0, 0, 0, 0, 0,
 -11,   6,  17,  21,  21,  17,   6, -11, 0, 0, 0, 0, 0, 0, 0, 0,
  -1,  15,  26,  30,  30,  26,  15,  -1, 0, 0, 0, 0, 0, 0, 0, 0,
   0,  17,  28,  32,  32,  28,  17,   0, 0, 0, 0, 0, 0, 0, 0, 0,
  -6,  11,  22,  26,  26,  22,  11,  -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -15,   1,  13,  17,  17,  13,   1, -15, 0, 0, 0, 0, 0, 0, 0, 0,
 -31, -15,  -4,   1,   1,  -4, -15, -31, 0, 0, 0, 0, 0, 0, 0, 0,
 -53, -37, -26, -22, -22, -26, -37, -53, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // bishop
 -1, -3, -6, -8, -8, -6, -3, -1, 0, 0, 0, 0, 0, 0, 0, 0,
 -3,  4,  1, -1, -1,  1,  4, -3, 0, 0, 0, 0, 0, 0, 0, 0,
 -6,  1,  8,  7,  7,  8,  1, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -8, -1,  7, 16, 16,  7, -1, -8, 0, 0, 0, 0, 0, 0, 0, 0,
 -8, -1,  7, 16, 16,  7, -1, -8, 0, 0, 0, 0, 0, 0, 0, 0,
 -6,  1,  8,  7,  7,  8,  1, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -3,  4,  1, -1, -1,  1,  4, -3, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -8,-11,-13,-13,-11, -8, -6, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // rook
 -7, -3,  1,  5,  5,  1, -3, -7, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -2,  2,  6,  6,  2, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // queen
-11, -7, -4, -2, -2, -4, -7,-11, 0, 0, 0, 0, 0, 0, 0, 0,
 -7, -1,  2,  4,  4,  2, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0,
 -4,  2,  6,  7,  7,  6,  2, -4, 0, 0, 0, 0, 0, 0, 0, 0,
 -2,  4,  7, 10, 10,  7,  4, -2, 0, 0, 0, 0, 0, 0, 0, 0,
 -2,  4,  7, 10, 10,  7,  4, -2, 0, 0, 0, 0, 0, 0, 0, 0,
 -4,  2,  6,  7,  7,  6,  2, -4, 0, 0, 0, 0, 0, 0, 0, 0,
 -7, -1,  2,  4,  4,  2, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0,
-16,-12, -9, -7, -7, -9,-12,-16, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // king
 -8, -3,-33,-52,-52,-33, -3, -8, 0, 0, 0, 0, 0, 0, 0, 0,
  2,  8,-22,-42,-42,-22,  8,  2, 0, 0, 0, 0, 0, 0, 0, 0,
 12, 18,-12,-32,-32,-12, 18, 12, 0, 0, 0, 0, 0, 0, 0, 0,
 17, 23, -7,-27,-27, -7, 23, 17, 0, 0, 0, 0, 0, 0, 0, 0,
 22, 28, -2,-22,-22, -2, 28, 22, 0, 0, 0, 0, 0, 0, 0, 0,
 25, 31,  1,-19,-19,  1, 31, 25, 0, 0, 0, 0, 0, 0, 0, 0,
 28, 33,  4,-16,-16,  4, 33, 28, 0, 0, 0, 0, 0, 0, 0, 0,
 31, 36,  6,-14,-14,  6, 36, 31, 0, 0, 0, 0, 0, 0, 0, 0, },
// mirror piece tables are filled in during init_eval
};


int endgame_piece_square_values[BK+1][0x80] = {
    {}, {}, {}, {}, {}, {}, {}, {}, {}, // empties to get indexing right
{ // pawn
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,
  6,  4,  2,  0,  0,  2,  4,  6, 0, 0, 0, 0, 0, 0, 0, 0,
  4,  2,  0, -2, -2,  0,  2,  4, 0, 0, 0, 0, 0, 0, 0, 0,
  3,  1, -1, -3, -3, -1,  1,  3, 0, 0, 0, 0, 0, 0, 0, 0,
  2,  0, -2, -4, -4, -2,  0,  2, 0, 0, 0, 0, 0, 0, 0, 0,
  1, -1, -3, -5, -5, -3, -1,  1, 0, 0, 0, 0, 0, 0, 0, 0,
  1, -1, -3, -5, -5, -3, -1,  1, 0, 0, 0, 0, 0, 0, 0, 0,
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // knight
 -12,  -7,  -2,   1,   1,  -2,  -7, -12, 0, 0, 0, 0, 0, 0, 0, 0,
  -5,   2,   6,   8,   8,   6,   2,  -5, 0, 0, 0, 0, 0, 0, 0, 0,
   0,   6,  11,  13,  13,  11,   6,   0, 0, 0, 0, 0, 0, 0, 0, 0,
  -1,   4,   9,  13,  13,   9,   4,  -1, 0, 0, 0, 0, 0, 0, 0, 0,
  -3,   2,   7,  11,  11,   7,   2,  -3, 0, 0, 0, 0, 0, 0, 0, 0,
  -7,  -1,   4,   6,   6,   4,  -1,  -7, 0, 0, 0, 0, 0, 0, 0, 0,
 -12,  -5,  -1,   1,   1,  -1,  -5, -12, 0, 0, 0, 0, 0, 0, 0, 0,
 -19, -14,  -9,  -6,  -6,  -9, -14, -19, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // bishop
  0, -1, -2, -2, -2, -2, -1,  0, 0, 0, 0, 0, 0, 0, 0, 0,
 -1,  1,  0,  0,  0,  0,  1, -1, 0, 0, 0, 0, 0, 0, 0, 0,
 -2,  0,  3,  2,  2,  3,  0, -2, 0, 0, 0, 0, 0, 0, 0, 0,
 -2,  0,  2,  5,  5,  2,  0, -2, 0, 0, 0, 0, 0, 0, 0, 0,
 -2,  0,  2,  5,  5,  2,  0, -2, 0, 0, 0, 0, 0, 0, 0, 0,
 -2,  0,  3,  2,  2,  3,  0, -2, 0, 0, 0, 0, 0, 0, 0, 0,
 -1,  1,  0,  0,  0,  0,  1, -1, 0, 0, 0, 0, 0, 0, 0, 0,
  0, -1, -2, -2, -2, -2, -1,  0, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // rook
 -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0,
  1,  1,  1,  1,  1,  1,  1,  1, 0, 0, 0, 0, 0, 0, 0, 0,
  1,  1,  1,  1,  1,  1,  1,  1, 0, 0, 0, 0, 0, 0, 0, 0,
  1,  1,  1,  1,  1,  1,  1,  1, 0, 0, 0, 0, 0, 0, 0, 0,
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0,  0,  0,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // queen
-11, -6, -4, -3, -3, -4, -6,-11, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -1,  1,  2,  2,  1, -1, -6, 0, 0, 0, 0, 0, 0, 0, 0,
 -4,  1,  4,  6,  6,  4,  1, -4, 0, 0, 0, 0, 0, 0, 0, 0,
 -3,  2,  6,  9,  9,  6,  2, -3, 0, 0, 0, 0, 0, 0, 0, 0,
 -3,  2,  6,  9,  9,  6,  2, -3, 0, 0, 0, 0, 0, 0, 0, 0,
 -4,  1,  4,  6,  6,  4,  1, -4, 0, 0, 0, 0, 0, 0, 0, 0,
 -6, -1,  1,  2,  2,  1, -1, -6, 0, 0, 0, 0, 0, 0, 0, 0,
-11, -6, -4, -3, -3, -4, -6,-11, 0, 0, 0, 0, 0, 0, 0, 0, },

{ // king
-42,-19, -3,  3,  3, -3,-19,-42, 0, 0, 0, 0, 0, 0, 0, 0,
-24,  1, 13, 19, 19, 13,  1,-24, 0, 0, 0, 0, 0, 0, 0, 0,
-13,  8, 23, 29, 29, 23,  8,-13, 0, 0, 0, 0, 0, 0, 0, 0,
 -7, 14, 29, 38, 38, 29, 14, -7, 0, 0, 0, 0, 0, 0, 0, 0,
-12,  9, 24, 33, 33, 24,  9,-12, 0, 0, 0, 0, 0, 0, 0, 0,
-18,  3, 18, 24, 24, 18,  3,-18, 0, 0, 0, 0, 0, 0, 0, 0,
-29, -4,  8, 14, 14,  8, -4,-29, 0, 0, 0, 0, 0, 0, 0, 0,
-62,-39,-23,-17,-17,-23,-39,-62, 0, 0, 0, 0, 0, 0, 0, 0, },
    // mirror piece tables are filled in during init_eval
};
